﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Krist_em_up.Characters.Enemies;
namespace Krist_em_up.Interface.Gui
{
    class HealthBar : Sprite
    {
        int hpMax, hp;
        Enemy victim;

        public HealthBar(Kristemup game, Enemy victim, int hpMax)
        {
            this.game = game;
            textureAsset = "barre";
            this.victim = victim;
            this.hpMax = hpMax;
            hp = hpMax;
            texture = game.Content.Load<Texture2D>(textureAsset);
        }
        public void DrawBar(SpriteBatch spriteBatch,Vector2 origin)
        {
            spriteBatch.Draw(texture,
                new Rectangle((int)(victim.Position.X + victim.Width() / 12 - texture.Width / 2 - origin.X),
                    (int)(victim.Position.Y - 12 - origin.Y), (int)(hp * texture.Width / hpMax),
                    (int)(texture.Height)), Color.Red);
        }

        public void hurt(int shooter)
        {
            hp = hp-game.tabKris[shooter].Damage;
        }

        public int getHp()
        {
            return hp;
        }
    }
}
